<template>
	<el-card class="form-container">
		<el-form :model="dataForm" ref="dataForm" :rules="dataRule" @keyup.enter.native="dataFormSubmitHandle()" label-width="90px">
			<el-form-item label="订单编号" prop="orderCode">
				<el-input v-model="dataForm.orderCode" placeholder="请输入订单编号"></el-input>
			</el-form-item>
			<el-form-item label="订单类别" prop="orderType">
				<el-input v-model="dataForm.orderType" placeholder="请输入订单类别"></el-input>
			</el-form-item>
			<el-form-item label="创建时间" prop="createTime">
				<el-input v-model="dataForm.createTime" placeholder="请输入创建时间"></el-input>
			</el-form-item>
			<el-form-item label="完成时间" prop="finishTime">
				<el-input v-model="dataForm.finishTime" placeholder="请输入完成时间"></el-input>
			</el-form-item>
			<el-form-item label="支付时间" prop="payTime">
				<el-input v-model="dataForm.payTime" placeholder="请输入支付时间"></el-input>
			</el-form-item>
			<el-form-item label="发货时间" prop="deliveryTime">
				<el-input v-model="dataForm.deliveryTime" placeholder="请输入发货时间"></el-input>
			</el-form-item>
			<el-form-item label="关闭时间" prop="closeTime">
				<el-input v-model="dataForm.closeTime" placeholder="请输入关闭时间"></el-input>
			</el-form-item>
			<el-form-item label="订单状态" prop="orderStatus">
				<el-input v-model="dataForm.orderStatus" placeholder="请输入订单状态"></el-input>
			</el-form-item>
			<el-form-item label="订单备注" prop="orderRemark">
				<el-input v-model="dataForm.orderRemark" placeholder="请输入订单备注"></el-input>
			</el-form-item>
			<el-form-item label="订单商品总数" prop="orderGoodsTotalNumber">
				<el-input v-model="dataForm.orderGoodsTotalNumber" placeholder="请输入订单商品总数"></el-input>
			</el-form-item>
			<el-form-item label="邮费" prop="orderPostage">
				<el-input v-model="dataForm.orderPostage" placeholder="请输入邮费"></el-input>
			</el-form-item>
			<el-form-item label="订单总金额:指订单商品总金额,不包含邮费和优惠金额" prop="orderTotalPrice">
				<el-input v-model="dataForm.orderTotalPrice" placeholder="请输入订单总金额:指订单商品总金额,不包含邮费和优惠金额"></el-input>
			</el-form-item>
			<el-form-item label="订单优惠总金额" prop="orderTotalDiscountPrice">
				<el-input v-model="dataForm.orderTotalDiscountPrice" placeholder="请输入订单优惠总金额"></el-input>
			</el-form-item>
			<el-form-item label="支付方式 1.支付宝 2.微信 3.银联 4.钱包 5.混合" prop="payType">
				<el-input v-model="dataForm.payType" placeholder="请输入支付方式 1.支付宝 2.微信 3.银联 4.钱包 5.混合"></el-input>
			</el-form-item>
			<el-form-item label="订单来源  网页:pc、 安卓:android、 苹果:ios、 M站:m、公众号:common、 小程序:small、 安卓平板:android_ipad、苹果平板:ios_ipad"
			 prop="orderSourceType">
				<el-input v-model="dataForm.orderSourceType" placeholder="请输入订单来源  网页:pc、 安卓:android、 苹果:ios、 M站:m、公众号:common、 小程序:small、 安卓平板:android_ipad、苹果平板:ios_ipad"></el-input>
			</el-form-item>
			<el-form-item label="用户编号" prop="userCode">
				<el-input v-model="dataForm.userCode" placeholder="请输入用户编号"></el-input>
			</el-form-item>
			<el-form-item label="关闭原因" prop="closeDesc">
				<el-input v-model="dataForm.closeDesc" placeholder="请输入关闭原因"></el-input>
			</el-form-item>
			<el-form-item label="支付回调流水号" prop="returnPayNo">
				<el-input v-model="dataForm.returnPayNo" placeholder="请输入支付回调流水号"></el-input>
			</el-form-item>
			<el-form-item label="订单有效性 1.有效 2删除 主要面对用户主动删除标志" prop="orderEffectiveStatus">
				<el-input v-model="dataForm.orderEffectiveStatus" placeholder="请输入订单有效性 1.有效 2删除 主要面对用户主动删除标志"></el-input>
			</el-form-item>
			<el-form-item label="收货人名称" prop="receiverName">
				<el-input v-model="dataForm.receiverName" placeholder="请输入收货人名称"></el-input>
			</el-form-item>
			<el-form-item label="收件人手机号" prop="receiverPhone">
				<el-input v-model="dataForm.receiverPhone" placeholder="请输入收件人手机号"></el-input>
			</el-form-item>
			<el-form-item label="省份名称" prop="provinceName">
				<el-input v-model="dataForm.provinceName" placeholder="请输入省份名称"></el-input>
			</el-form-item>
			<el-form-item label="城市名称" prop="cityName">
				<el-input v-model="dataForm.cityName" placeholder="请输入城市名称"></el-input>
			</el-form-item>
			<el-form-item label="区域名称" prop="areaName">
				<el-input v-model="dataForm.areaName" placeholder="请输入区域名称"></el-input>
			</el-form-item>
			<el-form-item label="具体地址" prop="orderAddress">
				<el-input v-model="dataForm.orderAddress" placeholder="请输入具体地址"></el-input>
			</el-form-item>
			<el-form-item label="订单实际应付金额" prop="orderActualPrice">
				<el-input v-model="dataForm.orderActualPrice" placeholder="请输入订单实际应付金额"></el-input>
			</el-form-item>
			<el-form-item label="提取方式 1.快递 2.包邮 3.自提" prop="extractionType">
				<el-input v-model="dataForm.extractionType" placeholder="请输入提取方式 1.快递 2.包邮 3.自提"></el-input>
			</el-form-item>
			<el-form-item label="订单更新时间" prop="updateTime">
				<el-input v-model="dataForm.updateTime" placeholder="请输入订单更新时间"></el-input>
			</el-form-item>
			<el-form-item label="物流名称" prop="expressName">
				<el-input v-model="dataForm.expressName" placeholder="请输入物流名称"></el-input>
			</el-form-item>
			<el-form-item label="物流单号" prop="expressNo">
				<el-input v-model="dataForm.expressNo" placeholder="请输入物流单号"></el-input>
			</el-form-item>
			<el-form-item label="评论状态 1.已评论 2.未评论" prop="commentStatus">
				<el-input v-model="dataForm.commentStatus" placeholder="请输入评论状态 1.已评论 2.未评论"></el-input>
			</el-form-item>
			<el-form-item label="是否包含 眼镜指需要用户提供眼镜度数的眼镜 1.是 2.否" prop="includingGlasses">
				<el-input v-model="dataForm.includingGlasses" placeholder="请输入是否包含 眼镜指需要用户提供眼镜度数的眼镜 1.是 2.否"></el-input>
			</el-form-item>
			<el-form-item label="用户视力详情,通过JSON存储,仅当订单中存在眼镜商品时候存在" prop="userEyesDetail">
				<el-input v-model="dataForm.userEyesDetail" placeholder="请输入用户视力详情,通过JSON存储,仅当订单中存在眼镜商品时候存在"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button @click="cancel">取消</el-button>
				<el-button type="primary" @click="submit('dataForm')">确定</el-button>
			</el-form-item>
		</el-form>
	</el-card>
</template>

<script>
	import {
		createOrder
	} from '@/api/admin/order'
	export default {
		name: 'add-order',
		data() {
			return {
				dataForm: {
					orderCode: ''
					orderType: ''
					createTime: ''
					finishTime: ''
					payTime: ''
					deliveryTime: ''
					closeTime: ''
					orderStatus: ''
					orderRemark: ''
					orderGoodsTotalNumber: ''
					orderPostage: ''
					orderTotalPrice: ''
					orderTotalDiscountPrice: ''
					payType: ''
					orderSourceType: ''
					userCode: ''
					closeDesc: ''
					returnPayNo: ''
					orderEffectiveStatus: ''
					receiverName: ''
					receiverPhone: ''
					provinceName: ''
					cityName: ''
					areaName: ''
					orderAddress: ''
					orderActualPrice: ''
					extractionType: ''
					updateTime: ''
					expressName: ''
					expressNo: ''
					commentStatus: ''
					includingGlasses: ''
					userEyesDetail: ''
				},
				dataRule: {
					orderCode: [{
							required: true,
							message: '请输入订单编号',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					orderType: [{
							required: true,
							message: '请输入订单类别',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					createTime: [{
							required: true,
							message: '请输入创建时间',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					finishTime: [{
							required: true,
							message: '请输入完成时间',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					payTime: [{
							required: true,
							message: '请输入支付时间',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					deliveryTime: [{
							required: true,
							message: '请输入发货时间',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					closeTime: [{
							required: true,
							message: '请输入关闭时间',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					orderStatus: [{
							required: true,
							message: '请输入订单状态',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					orderRemark: [{
							required: true,
							message: '请输入订单备注',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					orderGoodsTotalNumber: [{
							required: true,
							message: '请输入订单商品总数',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					orderPostage: [{
							required: true,
							message: '请输入邮费',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					orderTotalPrice: [{
							required: true,
							message: '请输入订单总金额:指订单商品总金额,不包含邮费和优惠金额',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					orderTotalDiscountPrice: [{
							required: true,
							message: '请输入订单优惠总金额',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					payType: [{
							required: true,
							message: '请输入支付方式 1.支付宝 2.微信 3.银联 4.钱包 5.混合',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					orderSourceType: [{
							required: true,
							message: '请输入订单来源  网页:pc、 安卓:android、 苹果:ios、 M站:m、公众号:common、 小程序:small、 安卓平板:android_ipad、苹果平板:ios_ipad',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					userCode: [{
							required: true,
							message: '请输入用户编号',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					closeDesc: [{
							required: true,
							message: '请输入关闭原因',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					returnPayNo: [{
							required: true,
							message: '请输入支付回调流水号',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					orderEffectiveStatus: [{
							required: true,
							message: '请输入订单有效性 1.有效 2删除 主要面对用户主动删除标志',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					receiverName: [{
							required: true,
							message: '请输入收货人名称',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					receiverPhone: [{
							required: true,
							message: '请输入收件人手机号',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					provinceName: [{
							required: true,
							message: '请输入省份名称',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					cityName: [{
							required: true,
							message: '请输入城市名称',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					areaName: [{
							required: true,
							message: '请输入区域名称',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					orderAddress: [{
							required: true,
							message: '请输入具体地址',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					orderActualPrice: [{
							required: true,
							message: '请输入订单实际应付金额',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					extractionType: [{
							required: true,
							message: '请输入提取方式 1.快递 2.包邮 3.自提',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					updateTime: [{
							required: true,
							message: '请输入订单更新时间',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					expressName: [{
							required: true,
							message: '请输入物流名称',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					expressNo: [{
							required: true,
							message: '请输入物流单号',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					commentStatus: [{
							required: true,
							message: '请输入评论状态 1.已评论 2.未评论',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					includingGlasses: [{
							required: true,
							message: '请输入是否包含 眼镜指需要用户提供眼镜度数的眼镜 1.是 2.否',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
					userEyesDetail: [{
							required: true,
							message: '请输入用户视力详情,通过JSON存储,仅当订单中存在眼镜商品时候存在',
							trigger: 'blur'
						},
						{
							min: 3,
							max: 20,
							message: '长度在 3 到 20 个字符',
							trigger: 'blur'
						}
					]
				}
			}
		},
		methods: {
			cancel() {
				this.$router.go(-1)
			},
			submit() {
				const set = this.$refs;
				set['dataForm'].validate((valid) => {
					if (!valid) {
						return false
					}
					createOrder(this.dataForm).then(() => {
						this.$notify({
							title: '添加成功',
							message: '添加成功',
							type: 'success',
							duration: 2000,
							onClose: this.$router.go(-1)
						})
					})
				})
			}
		}
	}
</script>

<style>
</style>
